package com.guchenbo.springboot;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

@RestController
@RequestMapping("/")
public class IndexController {

    @Resource
    private WebSocketServer webSocketServer;

    @GetMapping("/ok")
    public String ok() {
        return "ok";
    }

    @GetMapping("/send/{userId}")
    public String send(@PathVariable("userId") String userId, Subject subject) {
        webSocketServer.sendSubject(userId, subject);
        return "send";
    }
}
